function [ net ] = backPropagation( net, input, Vs, LEARNING_RATE)
%BACKPROPAGATION Summary of this function goes here
%   Detailed explanation goes here
layers = size(net,2);


s = size(input,2);
for i=1:s
    if(input(i) == 1)
        trainingResult(i) = 1;
    else
        trainingResult(i) = -1;
    end
end

%output layer
s_lay = size(Vs{layers},1)-1;
s_lay_1 = size(Vs{layers+1},1)-1;
h = net{layers}*Vs{layers};
deltaOutput = outputDelta(h, Vs{layers+1}(1:s_lay_1,:), trainingResult);




%hidden layers
deltas{layers}= deltaOutput;
for i=(layers-1):-1:1
    h= net{i}*Vs{i};
    deltas{i} = hiddenDelta(h, net{i+1}, deltas{i+1});
end

%modificar los pesos de las capas
%para cada capa (desde la salida hasta la entrada)
for m=layers:-1:1
    %para cada fila de la capa m
    for i=i:size(net{m},1)
        %para cada columna de la fila i de la capa m
        for j=1:size(net{m},2)
            deltaW=LEARNING_RATE * deltas{m}(i) * Vs{m}(j);
            net{m}(i,j) = net{m}(i,j) + deltaW;
        end
    end
end








